<?php

/**
 * 用户模型
 */
if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );

class Group_model extends MY_Model
{

    public $_table = array(
        'group' => 'group',
    );
    public $_fields = array(
        'group' => array(
            'id' => 'id',
            'name' => 'name',
            'default' => 'default',
        ),
    );

    /**
     * 获取默认组数据
     * @return array
     */
    public function getDefault()
    {
        return $this->db->select( 'id,name,default' )
                        ->from( $this->_table['group'] )
                        ->where( 'default', 1 )
                        ->get()
                        ->row_array();
    }

    /**
     * 根据组ID获取组数据
     * @param int $groupid 组ID
     * @return array
     */
    public function getByGroupId( $groupid )
    {
        return $this->db->from( $this->_table['group'] )
                        ->where( 'id', $groupid )
                        ->get()
                        ->row_array();
    }
    
}

?>
